<script src="<?=base_url(); ?>theme/js/main.js"></script>
<script type="text/javascript">
                                                            
$(document).ready(function(){
$('.table_top').hide(); //Oculta la parte de búsqueda por defecto de la tabla de productos .
});

</script>

<div class="grid_container">
	<div class="grid_12">
		<div class="widget_wrap">
			<div class="widget_top">
				<span class="h_icon clipboard"></span>
				<h6>Stock de Productos</h6>
			</div>
			<div class="form_container">
				<ul>
					<li>
						<div class="form_grid_12">
					
							<div class="form_input">
							
							<form method="post" action="">
								<div class="form_grid_2 alpha">
									<input name="code" type="text" value="<?php echo $code; ?>">
									<span class=" label_intro">Código</span>
								</div>
								<div class="form_grid_5 ">
									<input name="description" type="text" value="<?php echo $description; ?>" style=" width:80%">
									<span class=" label_intro">Descripción</span>
								</div>
								<div class="form_grid_2 ">
								<input type="submit" class="btn_small btn_blue" value="Buscar">
								</div>
								<span class="clear"></span>
							</form>
							</div>
						</div>
					</li>
				</ul>
			</div>

                    


<div id="view_stock" style="display:none;">
                                

                            </div>
<div class="widget_content">
				<table class="display data_tbl">
					<thead>
						<tr>
							<th>Código</th>
							<th>Descripción</th>
							<th>Precio</th>
							<th>Por Mayor</th>                                                        
							<th>Ver Stock</th>
						</tr>
					</thead>
					<tbody>
					<?php $i = 0; ?>
					<?php foreach ($products as $p) : ?>
					    <?php $i++; ?>
                                            
						<tr class="stockProduct tr_even" codeProduct="<?php echo $p->code ?>" style="cursor: pointer;">
							<td><?=$p->code; ?></td>
							<td><?=$p->description; ?></td>
							<td align="right">US$ <?=$p->price; ?></td>
							<td align="center"><?=$p->pack_desc; ?></td>
                                                       
							<td align="center">
                                                            
                                                            <script type="text/javascript">
                                                                    $(document).ready(function(){
                                                                         
                                                                            $('#view_stock_<?= $i; ?>').click(function(){
                                                                           var codigo = '<?=$p->code; ?>'
                                                                            $.ajax({
                                                                                'url' : url+'/stock/stockview/',
                                                                                'type' : 'POST',
                                                                                'data' : {'code' : codigo},                                                                             
                                                                                'success' : function(res){
                                                                                  $('#view_stock').html(res);
                                                                                }
                                                                            });
                                                                            
                                                                             $('.data_tbl').fadeOut('fast');
                                                                             $('.table_bottom').fadeOut('fast');
                                                                            $('#view_stock').fadeIn('show');
                                                                        });
                                                                        
                                                                       
                                                                        
                                                                    });
                                                            </script>
                                                            
                                                            
                                                                     <span id="view_stock_<?= $i; ?>"  class="action-icons c-view" original-title="Stock">Stock</span>
                                                           
                                                        </td>
						</tr>
                                          <?php endforeach; ?>
					</tbody>
				</table>
                            
			</div>
		</div>
	</div>
    
    
    
	<span class="clear"></span>
</div>